#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "inst.h"

struct chs {
	unsigned short c;
	unsigned char h;
	unsigned char s;
};

struct chs fchs( unsigned char* pchs )
{
	struct chs rchs;

	rchs.c = pchs[2] | ( ( pchs[1] & 0xC0 ) << 2 );
	rchs.h = pchs[0];
	rchs.s = pchs[1] & 0x3F;

	return rchs;

}

int main(void)
{
	struct par_rec *p;
	struct par_table *pt;
	struct stage1 st1;
	struct stage2 st2;
	struct chs schs;
	int fd, i;
	
	printf ( "%d", sizeof(st2) );
	return 0;
	fd = open( "/dev/hda", O_RDONLY);
	read( fd, &st1, 512);
	close( fd );
	
	pt = (struct par_table*) st1.pt;
	
	for ( i = 0; i < 4; i++ )
	{
	    p = pt->par+i;
	    printf ( "%2X %10d %10d %2x ", p->bootable, p->lba, p->length, p->type );
		schs = fchs( p->s_chs );
	    printf ( "%4d %4d %4d ", schs.c, schs.h, schs.s );
		schs = fchs( p->e_chs );
	    printf ( "%4d %4d %4d\n", schs.c, schs.h, schs.s );
	}

	return 0;
}

